﻿using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Aliyun
{
    internal class ConfigHelper
    {
        private readonly IConfiguration configuration;
        public ConfigHelper(IConfiguration _configuration)
        {
            this.configuration = _configuration;
        }
        public BucketEndPoint GetBucketEndPoint(string bucket)
        {
            var buckets = this.configuration["OSSBuckets"];
            List<BucketEndPoint> endpoints = JsonConvert.DeserializeObject<List<BucketEndPoint>>(buckets);
            return endpoints.Find(x => x.Bucket == bucket);
        }
    }
}
